// @Description: 注册提供系统web相关的路由
package routers

import (
    "github.com/astaxie/beego"
    "cloud_worm/wormweb/controllers"
    "cloud_worm/wormweb/controllers/ctrsecurity/monitor"
    "cloud_worm/wormweb/controllers/ctrdashboard"
    "cloud_worm/wormweb/controllers/ctrinner/analyzer"
    "cloud_worm/wormweb/controllers/ctrhost"
    "cloud_worm/wormweb/controllers/ctrsystem/weapon"
    "cloud_worm/wormweb/controllers/ctrsecurity/crontask"
)

func init()  {
    /**********************
      首页
    */
    /* 前端展示相关 */
    // *** 首页
    beego.Router("/", &controllers.MainController{})

    /**********************
      web中监控规则的管理
    */
    // cmd white list
    beego.Router("/monitor/cmd/white/list", &monitor.CmdWhiteController{}, "get:List")
    beego.Router("/monitor/cmd/white/create", &monitor.CmdWhiteController{}, "post:Create")
    beego.Router("/monitor/cmd/white/edit", &monitor.CmdWhiteController{}, "post:Edit")
    beego.Router("/monitor/cmd/white/commit", &monitor.CmdWhiteController{}, "post:Commit")
    beego.Router("/monitor/cmd/white/commit_flag", &monitor.CmdWhiteController{}, "get:CommitFlag")
    beego.Router("/monitor/cmd/enable/set", &monitor.CmdWhiteController{}, "post:EnableSet")
    beego.Router("/monitor/cmd/enable/get", &monitor.CmdWhiteController{}, "get:EnableGet")
    // file list monitor config
    beego.Router("/monitor/file/list", &monitor.FileListController{}, "get:List")
    beego.Router("/monitor/file/create", &monitor.FileListController{}, "post:Create")
    beego.Router("/monitor/file/edit", &monitor.FileListController{}, "post:Edit")
    beego.Router("/monitor/file/commit", &monitor.FileListController{}, "post:Commit")
    beego.Router("/monitor/file/commit_flag", &monitor.FileListController{}, "get:CommitFlag")
    beego.Router("/monitor/file/enable/set", &monitor.FileListController{}, "post:EnableSet")
    beego.Router("/monitor/file/enable/get", &monitor.FileListController{}, "get:EnableGet")
    // log collector monitor config
    beego.Router("/monitor/log/list", &monitor.LogCollectorController{}, "get:List")
    beego.Router("/monitor/log/create", &monitor.LogCollectorController{}, "post:Create")
    beego.Router("/monitor/log/edit", &monitor.LogCollectorController{}, "post:Edit")
    beego.Router("/monitor/log/commit", &monitor.LogCollectorController{}, "post:Commit")
    beego.Router("/monitor/log/commit_flag", &monitor.LogCollectorController{}, "get:CommitFlag")
    beego.Router("/monitor/log/enable/set", &monitor.LogCollectorController{}, "post:EnableSet")
    beego.Router("/monitor/log/enable/get", &monitor.LogCollectorController{}, "get:EnableGet")
    beego.Router("/monitor/log/parser", &monitor.LogCollectorController{}, "get:ListParser")

    /**********************
      计划任务管理
	*/
    beego.Router("/cron/task/create", &crontask.CronController{}, "post:CreateCron")
    beego.Router("/cron/model/job", &crontask.CronController{}, "get:AllJobModeName")
    beego.Router("/cron/task/edit", &crontask.CronController{}, "post:EditCron")
    beego.Router("/cron/task/update", &crontask.CronController{}, "post:UpdateCron")
    beego.Router("/cron/task/list", &crontask.CronController{}, "get:List")
    beego.Router("/cron/task/do/detail", &crontask.CronController{}, "get:TaskDoDetail")

    /**********************
      weapon管理相关
	*/
    beego.Router("/weapon/mode/list", &weapon.WpController{}, "get:WpTaskModeList")
    beego.Router("/weapon/type/list", &weapon.WpController{}, "get:WpTypeList")
    beego.Router("/weapon/list", &weapon.WpController{}, "get:List")
    beego.Router("/weapon/insert", &weapon.WpController{}, "post:Insert")
    beego.Router("/weapon/update", &weapon.WpController{}, "post:Update")
    beego.Router("/weapon/select", &weapon.WpController{}, "get:Select")
    // weapon文件上传
    beego.Router("/weapon/upload", &weapon.WpUploadController{})

    /**********************
      weapon任务task相关
	*/
    beego.Router("/weapon/task/create", &weapon.TaskController{}, "post:CreateTask")
    beego.Router("/weapon/task/exec", &weapon.TaskController{}, "post:ExecTask")
    beego.Router("/weapon/task/list", &weapon.TaskController{}, "get:List")
    beego.Router("/weapon/task/select", &weapon.TaskController{}, "get:Select")
    beego.Router("/weapon/weapon/log/list", &weapon.TaskWeaponLogController{}, "get:List")                   // todo: weapon log相关的，后续再考虑如何处理
    beego.Router("/weapon/task/report/alert", &weapon.AlertReportController{}, "get:GetReportByTaskId")
    // todo: 缺alert相关的信息，考虑在什么时候执行相关操作最好

    /**********************
 	  应用管理 && 连接管理
	*/
    beego.Router("/host/platform/list", &ctrhost.AgentController{}, "get:PlatformList")
    beego.Router("/host/version/list", &ctrhost.AgentController{}, "get:VersionList")
    beego.Router("/host/access_srv/list", &ctrhost.AgentController{}, "get:AccessSrvList")
    beego.Router("/host/connect/all", &ctrhost.AgentController{}, "get:List") /* 在线情况 */

    // 应用初步管理
    beego.Router("/host/apply/all/name", &ctrhost.ApplyController{}, "get:NameList")
    beego.Router("/host/apply/all", &ctrhost.ApplyController{}, "get:List")
    beego.Router("/host/apply/select", &ctrhost.ApplyController{}, "get:Select") /* 应用详情 */
    beego.Router("/host/apply/machines", &ctrhost.MachineController{}, "get:ListMachine")

    // 基于主机、应用启动创建weapon task
    beego.Router("/apply/weapon/task/create", &ctrhost.ApplyWeaponTaskController{}, "post:Create")
    beego.Router("/host/weapon/task/create", &ctrhost.MachineWeaponTaskController{}, "post:Create")

	// 查看host的具体详情
	beego.Router("/host/analyzer", &analyzer.DoAnalyzerController{}, "post:DoAnalyzer")				// todo：待实现
	beego.Router("/host/detail/list", &ctrhost.MachineDetailController{}, "get:DetailList")			// todo: 优化
	beego.Router("/host/detail/name/:name", &ctrhost.MachineDetailController{}, "get:NameDetail")	// todo: 优化
	beego.Router("/host/alert/list", &ctrhost.MachineAlertController{}, "get:AlertList")			// todo: 优化
	beego.Router("/host/alert/name/:name", &ctrhost.MachineAlertController{}, "get:AlertOptionList")// todo: 优化
	beego.Router("/host/apply/ips", &ctrhost.ApplyController{}, "get:IPsList")

    /**********************
	  数据面板相关
	*/

    /* 首页面板数据 */// 给应用dashboard的总数据返回信息：
    beego.Router("/dashboard/analyze/first/machine_cnt", &ctrdashboard.FirstRowCtr{}, "get:MachineInfo")
    beego.Router("/dashboard/analyze/first/online_rate", &ctrdashboard.FirstRowCtr{}, "get:OnlineRate")
    beego.Router("/dashboard/analyze/first/task_cnt", &ctrdashboard.FirstRowCtr{}, "get:TaskCnt")
    beego.Router("/dashboard/analyze/first/alert_cnt", &ctrdashboard.FirstRowCtr{}, "get:AlertCnt")

    beego.Router("/dashboard/alert/content/first_layer", &ctrdashboard.AlertContentCtr{}, "get:FirstLayer")
    beego.Router("/dashboard/alert/content/second_layer", &ctrdashboard.AlertContentCtr{}, "get:SecondLayer")
    beego.Router("/dashboard/alert/content/third_layer", &ctrdashboard.AlertContentCtr{}, "get:ThirdLayer")
    beego.Router("/dashboard/alert/content/export", &ctrdashboard.AlertContentCtr{}, "get:ExportNumberFile")

    beego.Router("/dashboard/agent/cnt", &ctrdashboard.DbdAgentController{})
    beego.Router("/dashboard/task/cnt", &ctrdashboard.DbdTaskCntController{})
    beego.Router("/dashboard/alert/cnt", &ctrdashboard.DbdAlertCntController{})
    // 之前涉及的dashboard
    beego.Router("/host/dashboard/all", &ctrhost.CountController{}, "get:GetAllHostCount")
    beego.Router("/host/recent/change", &ctrhost.CountController{}, "get:RecentChange")
    beego.Router("/host/dashboard/time", &ctrhost.CountController{}, "get:GetAllHostCountWithTime")
    // 获取所有的主机在connect信息，实时的,分页,可以多个条件查询
}
